/*
 * @Author: 姚潘涛
 * @Date: 2024-06-04 10:08:17
 * @LastEditors: 姚潘涛
 * @LastEditTime: 2024-10-10 18:57:18
 * @Description:
 *
 * Copyright (c) 2024 by pandaman, All Rights Reserved.
 */
#pragma once

#include "xict_common/perception/common/utils.h"
#include "xict_common/perception/detection/yolo_detect.h"
#include "xict_common/utils/types.h"
#include <opencv2/opencv.hpp>

namespace xict_common {
    namespace perception {
        namespace detection {
            cv::Rect GetRect(cv::Mat& img, float bbox[4]);

            void Nms(std::vector<xict_common::utils::Detection>& res,
                     float* output, float conf_thresh, float nms_thresh = 0.5);

            void
            BatcNms(std::vector<std::vector<xict_common::utils::Detection>>&
                        batch_res,
                    float* output, int batch_size, int output_size,
                    float conf_thresh, float nms_thresh = 0.5);

            void
            DrawBbox(std::vector<cv::Mat>& img_batch,
                     std::vector<std::vector<xict_common::utils::Detection>>&
                         res_batch);

            void DrawBboxWithResult(
                std::vector<cv::Mat>& img_batch,
                std::vector<std::vector<xict_common::utils::Detection>>&
                    res_batch,
                struct_yolo_result& result);

            void DrawBboxWithResultBatch(
                std::vector<cv::Mat>& img_batch,
                std::vector<std::vector<xict_common::utils::Detection>>&
                    res_batch,
                std::vector<struct_yolo_result>& result);

            std::vector<cv::Mat>
            ProcessMask(const float* proto, int proto_size,
                        std::vector<xict_common::utils::Detection>& dets);

            void DrawMaskBbox(cv::Mat& img,
                              std::vector<xict_common::utils::Detection>& dets,
                              std::vector<cv::Mat>& masks,
                              std::unordered_map<int, std::string>& labels_map);
        }   // namespace detection
    }       // namespace perception
}   // namespace xict_common